package com.eduhzy.ttw.clazz.di.module;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.eduhzy.ttw.clazz.R;
import com.eduhzy.ttw.clazz.mvp.contract.GroupReviewContract;
import com.eduhzy.ttw.clazz.mvp.model.GroupReviewModel;
import com.eduhzy.ttw.clazz.mvp.model.entity.ReviewGroupData;
import com.eduhzy.ttw.commonsdk.holder.AutoBaseViewHolder;
import com.jess.arms.di.scope.FragmentScope;

import java.util.ArrayList;
import java.util.List;

import dagger.Module;
import dagger.Provides;

/**
 * @author xubo
 * @date 2018-12-5 15:35:22
 */
@Module
public class GroupReviewModule {
    private GroupReviewContract.View view;

    /**
     * 构建GroupReviewModule时,将View的实现类传进来,这样就可以提供View的实现类给presenter
     *
     * @param view
     */
    public GroupReviewModule(GroupReviewContract.View view) {
        this.view = view;
    }

    @FragmentScope
    @Provides
    GroupReviewContract.View provideGroupReviewView() {
        return this.view;
    }

    @FragmentScope
    @Provides
    GroupReviewContract.Model provideGroupReviewModel(GroupReviewModel model) {
        return model;
    }
    
    @FragmentScope
    @Provides
    List<ReviewGroupData> provideLists() {
        return new ArrayList<>();
    }
    @FragmentScope
    @Provides
    BaseQuickAdapter<ReviewGroupData, AutoBaseViewHolder> providerAdapter(List<ReviewGroupData> lists) {
        return new BaseQuickAdapter<ReviewGroupData, AutoBaseViewHolder>(R.layout.clazz_rv_item_review_group, lists) {
            @Override
            protected void convert(AutoBaseViewHolder helper, ReviewGroupData item) {
                helper.setText(R.id.btn_add, item.getPraiseScore() + "");
                helper.setText(R.id.btn_del, item.getImprovingScore() + "");
                helper.setText(R.id.tv_title, item.getTeamName());
                helper.setText(R.id.tv_name, item.getStudentNames());
                helper.setText(R.id.tv_count, item.getStudentCount() + "人");

            }
        };

    }
    @FragmentScope
    @Provides
    RecyclerView.LayoutManager provideLayoutManager(){
        return new LinearLayoutManager(view.getActivity());
    }


}